# 将类序列化
import json

class Student:
    name:str
    age:int

    def __init__(self,name,age):
        self.name=name
        self.age=age

if __name__ == '__main__':
    stu=Student("张三",34)

    # stu_str=json.dumps(stu,default=lambda ele:ele.__dict__,sort_keys=True,indent=4,ensure_ascii=False)
    stu_str=json.dumps(stu,default=lambda ele:ele.__dict__,sort_keys=True,ensure_ascii=False)
    print(stu_str)

    stu2=Student(**json.loads(stu_str))
    print(f"name={stu2.name},age={stu2.age}")